
const request = require('request');

class Util{


    static httpGet(url,callback){
        request(url,function(err,response,body){
            if(err){
                callback(undefined);
                return;
            }

            if(response.statusCode == 200){
                callback(body);
                return;
            }

            callback(undefined);

        })
    }

    static httpPost(url,data,callback){
        request({
            url: url,
            method: "POST",
            json: true,
            headers: {
                "content-type": "application/json",
            },
            body:data
        },function(err,response,body){
            if(err){
                callback(undefined);
                return;
            }

            if(response.statusCode == 200){
                callback(body);
                return;
            }

            callback(undefined);
        })
    }

}


module.exports.Util = Util;